<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联后台管理系统</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('ADMIN_IMAGE')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('ADMIN_CSS')}admin.css">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

<!-- header start-->

<include file="Public:header"/>

<!-- header end-->

<div class="am-cf admin-main">
<!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->
  
  <!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">品牌管理</strong> / <small>品牌列表</small></div>
    </div>
    <div class="am-g">


    <div class="am-u-md-3 am-cf">

     
    <button type="button" class="am-btn am-btn-primary am-btn-xs"><a href="{:U('Brand/addBrand')}" style="color:#fff">添加品牌</a></button>
  </div>
      <div class="am-u-md-3 am-cf" style="float:right">
        <div class="am-fr">
          <div class="am-input-group am-input-group-sm">
            <input type="text" class="am-form-field" name="keywords">
                <span class="am-input-group-btn">
                  <button class="am-btn am-btn-primary" type="button" id="searbrand" >搜索</button>
                </span>
          </div>
        </div>
      </div>
    </div>
    <div class="am-g">
      <div class="am-u-sm-12">
       
          <table class="am-table am-table-striped am-table-hover table-main  brandtalbe" >
            <thead>
              <tr>
                <th class="table-check">
                <input type="checkbox" />
                </th>
                <th class="table-id">ID</th>
                <th class="table-title">品牌名称</th>
                <th class="table-date">生成日期</th>
                <th class="table-title">操作</th>
                
              </tr>
          </thead>
          <tbody>
            <foreach name="brands" item='brand'>
            <tr>
              <td><input type="checkbox" /></td>
              <td>{$brand['brandid']}</td>
              <td><a href="#">{$brand['brandname']}</a></td>
              <td>{$brand.createtime|date="Y-m-d ",###}</td>
              <td>
                <div class="">
                  <div class="am-btn-group am-btn-group-xs">
                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                    <span class="am-icon-pencil-square-o"><a  href="{:U('Brand/editBrand',array('brandid'=>$brand['brandid']))}">编辑</a></span> </button>
                    <button class="am-btn am-btn-default am-btn-xs am-text-danger">
                    <span class="am-icon-trash-o"> <a href="javascript:void(0)" onclick="ajaxdel({$brand['brandid']})"> 删除 </a> </span> </button>
                  </div>
                </div>
              </td>
            </tr>
            </foreach>
          </tbody>
        </table>
 <div class="am-cf brandpage">
  共 {$pagearr['count']}条记录  
  <div class="am-fr">
      <ul class="am-pagination">
        <li><a href="{:U('index',array('page'=>$pagearr['prevpage']))}">«</a></li>
         <?php $k=0; ?>
        <for start="$pagearr['page']" end="$pagearr['pagetotal']+1"  name='i' step="1">
           <if condition="$k lt 6">
             <li <if condition="$i eq $pagearr['page']"> class="am-active" </if>  > <a href="{:U('Brand/index',array('page'=>$i))}">{$i}</a></li>
           </if>
         <?php $k+=1;  ?>
        </for>
        
        <li><a href="{:U('Brand/index',array('page'=>$pagearr['nextpage']))}">»</a></li>
      </ul>
    </div>
</div>
        
      </div>

    </div>
  </div>
  <!-- content end -->
</div>

<script src="{:C('ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('ADMIN_JS')}app.js"></script>
<script src="{:C('ADMIN_JS')}admin.js"></script>
<script type="text/javascript">
  function ajaxdel(brandid){
    var res=confirm('删除此品牌前，请核对此品牌下是否有商品');
    //alert(typeof(res));return false;
    if(res==false){
      return false;
    }
    var bid=brandid;
    $.ajax({
      type:'POST',
      url:"{:U('Brand/ajaxDel')}",
      data:{'brandid':bid},
      dataType:"text",
      success:function(data)
      {
          if(data==1){
            alert('删除成功');
             location.reload();
          }else{
            alert('删除失败');
            event.preventDefault(); 
          }
      }
      }
      );
  }
</script>
</body>
</html>
